<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>东莞新华投票系统v1.0</title>
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <script src="js/jquery.js" type="text/javascript"></script>
    <script src="js/checkinput.js" type="text/javascript"></script>
    <script src="js/ajaxfileupload.js" type="text/javascript"></script>

</head>
<body id="manager-vote">

<?php
if(!isset($_COOKIE['islogin']) || $_COOKIE['islogin']!=1){
    echo "<script>window.location.href='login.php';</script>";
}
    if($_COOKIE['permission']!=1){
        echo "<script>alert('抱歉，你的权限不足。');window.location.href='index.php';</script>";
    }

require('config.php');
$select_query = "select vsID,title,deadDate,options from vote_subject where state='未开始'";
$select2_query= "select vsID,title,deadDate,options from vote_subject where state='进行中'";
$select3_query= "select vsID,title,deadDate,options from vote_subject where state='已结束'";
$result_select= mysql_query($select_query) or die(mysql_error());
$result_select2= mysql_query($select2_query) or die(mysql_error());
$result_select3= mysql_query($select3_query) or dir(mysql_error());
?>
<div id="nav">
    <div id="nav_top">
        <div class="width navs">
            <div class="logo">
                <a href="index.php" target="ifm"><img src="images/logo.png" width="290" height="54" /></a>
            </div>
            <div class="clear"></div>
        </div>
    </div>
    <div id="header">
        <div class="width">
            <div style="background: url(images/gx.gif) no-repeat; height: 48px;">
                <span style="float: right; font-size: 12px;">欢迎您：<?php echo $_COOKIE["username"];?>---<a href="login.php?action=logout">退出</a></span>
                <div id="top-nav">
                    <a id="1" href="index.php">首页</a>
                    <a id="2" href="my-vote.php" >我的投票</a>
                    <a id="3" href="create-vote.php" >创建投票</a>
                    <a id="4" href="manager-vote.php" class="curr">管理投票</a>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="content">
    <div id="main-content">
        <div style="border: 1px solid gray;">
            <h3>未开始的投票</h3>
            <table>
                <tr>
                    <th width="50">编号</th>
                    <th width="330">主题</th>
                    <th width="100">截止日期</th>
                    <th width="50">选择数</th>
                    <th width="200">操作</th>
                </tr>
                <?php
                    while($row=mysql_fetch_array($result_select))
                    {
                    ?>
                    <tr>
                        <td><?php echo $row['vsID']; ?></td>
                        <td><?php echo $row['title'];?></td>
                        <td><?php echo $row['deadDate'];?></td>
                        <td><?php echo $row['options'];?></td>
                        <td><a id="start_btn" class="btn btn-primary" href="start-vote.php?action=<?php echo $row['vsID'];?>">开始</a>
                            <a id="modify_btn" class="btn btn-warning">修改</a>
                            <a id="view_btn" class="btn btn-success" href="view-vote.php?action=<?php echo $row['vsID']; ?>" target="_blank">预览</a>
                            <a id="delete_btn" class="btn btn-danger" href="delete-vote.php?action=<?php echo $row['vsID']; ?>">删除</a>
                        </td>
                    </tr>
                <?php
                    }
                ?>

            </table>
        </div>
        <div style="border: 1px solid gray">
            <h3>正在进行的投票</h3>
            <table>
                <tr>
                    <th width="50">编号</th>
                    <th width="330">主题</th>
                    <th width="100">截止日期</th>
                    <th width="50">选择数</th>
                    <th width="200">操作</th>
                </tr>
                <?php
                while($row2=mysql_fetch_array($result_select2))
                {
                    ?>
                    <tr>
                        <td><?php echo $row2['vsID']; ?></td>
                        <td><?php echo $row2['title'];?></td>
                        <td><?php echo $row2['deadDate'];?></td>
                        <td><?php echo $row2['options'];?></td>
                        <td><a id="delete_btn" class="btn btn-danger" href="stop-vote.php?action=<?php echo $row2['vsID'] ?>">手动停止</a>
                            <a id="detail_btn" class="btn btn-success" href="detail-vote.php?action=<?php echo $row2['vsID']?>" target="_blank">投票进度</a>
                        </td>
                    </tr>
                <?php
                }
                ?>

            </table>

        </div>

        <div style="border: 1px solid gray">
            <h3>已结束的投票</h3>
            <table>
                <tr>
                    <th width="50">编号</th>
                    <th width="330">主题</th>
                    <th width="100">截止日期</th>
                    <th width="50">选择数</th>
                    <th width="200">操作</th>
                </tr>
                <?php
                while($row3=mysql_fetch_array($result_select3))
                {
                    ?>
                    <tr>
                        <td><?php echo $row3['vsID']; ?></td>
                        <td><?php echo $row3['title'];?></td>
                        <td><?php echo $row3['deadDate'];?></td>
                        <td><?php echo $row3['options'];?></td>
                        <td>
                            <a id="delete_btn" class="btn btn-primary" target="_blank" href="result-vote.php?action=<?php echo $row3['vsID']; ?>">投票结果</a>
                            <a id="detail_btn" class="btn btn-success" href="detail-vote.php?action=<?php echo $row3['vsID'];?>" target="_blank">投票明细</a>
                        </td>
                    </tr>
                <?php
                }
                ?>

            </table>

        </div>

    </div>
</div>
</body>
</html>